#pragma once

#include  "iostream"
#include  "vector"
#include  "stack"
#include  "unordered_map"
#include   "queue"

using namespace std;

struct Trie {
    Trie *child[26];//树有26个树叉
    string word = "";

    Trie() {
        for (int i = 0; i < 26; i++)
            child[i] = nullptr;
    }
};

//把树跟传过来
inline void insertTrie(std::string key, Trie *root) {
    auto cur = root;
    for (int i = 0; i < key.size(); i++) {
        if (cur->child[key[i] - 'a'] == nullptr) {
            cur->child[key[i] - 'a'] = new Trie();
        }
        cur = cur->child[key[i] - 'a'];

    }
    cur->word = key;//叶子节点存了一个

}

inline bool findTrie(string key, Trie *root) {
    auto cur = root;

    for (int i = 0; i < key.size(); ++i) {
        cur = cur->child[key[i] - 'a'];
        if (!cur)
            return false;
    }

    return true;


}